package com.yang.mall.controller;


import com.yang.mall.dto.LoginDTO;
import com.yang.mall.entity.Member;
import com.yang.mall.entity.OLResponse;
import com.yang.mall.service.IMemberService;
import com.yang.mall.tools.Utils;
import com.yang.mall.vo.MemberVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;

/**
 * <p>
 * 会员表 前端控制器
 * </p>
 *
 * @author kadorlin
 * @since 2022-10-21
 */
@Api(tags = "【小程序】会员模块")
@RestController
@RequestMapping("/h5/member")
public class MemberController {

    @Autowired
    private IMemberService memberService;

    @PostMapping(value = "/login")
    @ApiOperation(value = "密码登录")
    public OLResponse login(@RequestBody LoginDTO loginDTO) {
        MemberVO memberVO = memberService.login(loginDTO);
        return new OLResponse().success(memberVO);
    }

    @PostMapping(value = "/register")
    @ApiOperation(value = "会员注册")
    public OLResponse register(@RequestBody Member member) {
        memberService.register(member);
        return new OLResponse().success();
    }

    @PostMapping(value = "/update")
    @ApiOperation(value = "会员信息修改")
    public OLResponse update(@RequestBody Member member) {
        memberService.updateById(member);
        return new OLResponse().success();
    }

}
